#pragma once

#include "fxcc/core/platform/win32/pch.h"

struct FXCC_API WinTimer
{

	double m_StartTime;
	double m_TotalTime;

	double m_CurrentTime;
	double m_LastTime;
	double m_DeltaTime;

	LARGE_INTEGER frequency;
	LARGE_INTEGER counter;

	WinTimer() :
		m_StartTime(0),
		m_TotalTime(0),
		m_CurrentTime(0),
		m_LastTime(0),
		m_DeltaTime(0), 
		frequency(), 
		counter()
	{

	}
	double CurrentTime() const
	{
		return m_CurrentTime;
	}
	double DeltaTime() const
	{
		return m_DeltaTime;
	}

	void Start()
	{
		QueryPerformanceFrequency(&frequency);
		QueryPerformanceCounter(&counter);

		m_StartTime = static_cast<double>(counter.QuadPart) / frequency.QuadPart;

	}

	void Tick()
	{
		QueryPerformanceFrequency(&frequency);
		QueryPerformanceCounter(&counter);

		m_TotalTime = static_cast<double>(counter.QuadPart) / frequency.QuadPart;
		m_CurrentTime = m_TotalTime - m_StartTime;

		m_DeltaTime = m_CurrentTime - m_LastTime;
		m_LastTime = m_CurrentTime;
	}

};